package com.chen.manager.controller;

import com.chen.manager.service.SysMenuService;
import com.chen.model.entity.system.SysMenu;
import com.chen.model.vo.common.Result;
import com.chen.model.vo.common.ResultCodeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author cgj
 * @date 2/22/25 4:25 PM
 */
@RestController
//http://localhost:8501/admin/system/sysMenu/removeById/1
@RequestMapping("/admin/system/sysMenu")
public class SysMenuController {
    @Autowired
    private SysMenuService sysMenuService;

    /**
     * 查询所有
     * @return
     */
    @GetMapping("/showAll")
    public Result<List<SysMenu>> showAll(){
        List<SysMenu> sysMenuList=sysMenuService.showAll();
        return Result.build(sysMenuList, ResultCodeEnum.SUCCESS);
    }

    /**
     * 添加菜单
     * @param sysMenu
     * @return
     */
    @PostMapping("/add")
    public Result addSysMenu(@RequestBody SysMenu sysMenu){
        sysMenuService.add(sysMenu);
        return  Result.build(null,ResultCodeEnum.SUCCESS);
    }
    @PutMapping("/update")
    public Result updateSysMenu(@RequestBody SysMenu sysMenu){
        sysMenuService.update(sysMenu);
        return Result.build(null,ResultCodeEnum.SUCCESS);
    }
    
    @DeleteMapping("removeById/{id}")
    public Result removeSysMenuById(@PathVariable Long id){
        sysMenuService.removeSysMenuById(id);
        return Result.build(null,ResultCodeEnum.SUCCESS);
    }
}
